package com.pubinfo.passbook.common.model.bo.witeoff.subitem;

import com.pubinfo.passbook.common.config.ProfileConfig;
import com.pubinfo.passbook.common.model.ruler.UserAcc;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Value;

import javax.annotation.Resource;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 在职医药/退休医药子单数据,接收前端报账单数据
 */
@Data
@NoArgsConstructor
@ApiModel(value = "MedicineOnJobOrRetireSubitem", description = "在职医药/退休医药子单数据,接收前端报账单数据")
public class MedicineOnJobOrRetireSubitem extends SubitemBase implements Serializable {
  @Value("${spring.profiles.active}")
  private String env;
  private static final long serialVersionUID = 4085367428808251383L;
//  /**
//   * 借方科目类型	非必须	选项(1-总账、2-供应商、3-客户) ，当存在科目时，科目类型必填
//   * (在职及供属医药费) -  (退休员工医药费)-  下拉框选择
//   * (环保费) - (社会团体会费)不要此字段
//   */
//  @ApiModelProperty("借方科目类型 非必须 选项(1-总账、2-供应商、3-客户) ，当存在科目时，科目类型必填\n" +
//      "   * (在职及供属医药费) -  (退休员工医药费)-  下拉框选择\n" +
//      "   (环保费) - (社会团体会费)不要此字段")
//  private Byte debitAccountType;
  
  @ApiModelProperty("人员类别")
  private String staffTypeCode;
  
  /**
   * 报账单id
   */
  @ApiModelProperty(value = "报账单id", hidden = true)
  private String witeoffInstanceId;
  
  @Resource
  ProfileConfig config;
  
  /**
   * @param sum
   * @param type          类型 如果type为0 则为在职员工,为1,则为离退休员工
   * @param sapCompayCode 公司代码
   */
  public MedicineOnJobOrRetireSubitem(String profile, BigDecimal sum, Integer type, Boolean isGenus, String sapCompayCode, UserAcc userAcc) {
    //如果type为0 则为环保费,为1,则为社会团体费
    if (type == 1) {
      //U219 或U220
      this.usageCode = profile.contains("pro") ? "U349" : "U243";//生产 U349 测试环境 U243
      this.usageName = "补充医疗特需资金";
      this.budgetItemCode = "CW0230";
      this.budgetItemName = "职工福利";
      if (isGenus) {
        //供属为1
        this.budgetType = 1;
      } else {
        this.budgetType = 2;
      }
    } else {
      //生产 U541 测试环境 U165
      this.usageCode = "U541";
      this.usageName = "医疗及供养亲属医药费";
      this.budgetItemCode = "CW1144";
      this.budgetItemName = "离退休费用";
      this.budgetType = "A011".equals(sapCompayCode) ? 1 : 2;
    }
  
    this.budgetOrgCode = userAcc.getOrgCode();
    this.budgetOrgName = userAcc.getOrgName();
  
    //budgetType    desc
    this.sum = sum;
    this.priceSum = sum;
    //budgetOrgCode budgetOrgName sapCostCenterCode sapCostCenterName profitsCenterCode profitsCenterName
  
    this.desc = userAcc.getOrgName() + "报" + userAcc.getName() + "医药";
  }
}
